import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Home from '@/components/Home/home'
import HomePage from '@/components/Home/homepage/HomePage'
import Mall from '@/components/Home/mall/Mall'
import Classify from '@/components/Home/classify/Classify'
import Mine from '@/components/Home/mine/Mine'
import Seller from '@/components/Seller/seller'
import login from '@/components/Page/login'
import register from '@/components/Page/register'
Vue.use(Router)

const router = new Router({
  mode: 'history',
  linkActiveClass: 'active',
  routes: [
    {
      path: '/',
      redirect: '/homepage'
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {
          path: '/homepage',
          name: 'HomePage',
          component: HomePage
        },
        {
          path: '/classify',
          name: 'Classify',
          component: Classify
        },
        {
          path: '/mall',
          name: 'Mall',
          component: Mall
        },
        {
          path: '/mine',
          name: 'Mine',
          component: Mine
        }
      ]
    },
    {
      path: '/HelloWorld',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/seller',
      name: 'Seller',
      component: Seller
    }, {
      path: '/login',
      name: 'login',
      component: login
    }, {
      path: '/register',
      name: 'register',
      component: register
    }
  ]
})
router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title || '洋网店微商城'
  next()
})
export default router
